import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import VueAxios from 'vue-axios'
import { User,Lock,Setting,Search ,Tickets,ShoppingCartFull,WalletFilled
,UserFilled,Plus,House,DocumentCopy,SetUp} from '@element-plus/icons-vue' // 引入 House 图标

import vue3videoPlay from 'vue3-video-play' // 引入组件
import 'vue3-video-play/dist/style.css' // 引入css

import zhCn from 'element-plus/es/locale/lang/zh-cn'

import ElementPlus from 'element-plus'



// 导入index.css
import "element-plus/dist/index.css"




const app=createApp(App)
app.use(ElementPlus, {
    locale: zhCn,
  })
app.use(vue3videoPlay)
app.component(User.name, User) // 全局注册 House 图标
app.component(Lock.name, Lock) // 全局注册 House 图标
app.component(Setting.name, Setting) // 全局注册 House 图标
app.component(Search.name, Search) // 全局注册 House 图标
app.component(Tickets.name, Tickets) // 全局注册 House 图标
app.component(ShoppingCartFull.name, ShoppingCartFull) // 全局注册 House 图标
app.component(WalletFilled.name, WalletFilled) // 全局注册 House 图标
app.component(UserFilled.name, UserFilled) // 全局注册 House 图标
app.component(Plus.name, Plus) // 全局注册 House 图标
app.component(House.name, House) // 全局注册 House 图标
app.component(DocumentCopy.name, DocumentCopy) // 全局注册 House 图标
app.component(SetUp.name, SetUp) // 全局注册 House 图标
app.use(VueAxios,axios)
app.use(store)
app.use(router)
app.mount('#app')


axios.interceptors.request.use(function (config) {
    // console.log('config', config)    //这里可以打印一下看看里面内容
    // let token = localStorage.getItem("token");	//获取到从后端传来的token，然后存到session里面
    let token = store.state.token
    // console.log(token)
    if (token) {
      config.headers["token"] = token;	//然后赋值就行
    }
    return config
  }, function (error) {
    return Promise.reject(error)
})

